package com.ruoyi.system.controller;

import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.notificationResult.MonthCardResult;
import com.ruoyi.system.domain.notificationResult.MonthNotification;
import com.ruoyi.system.domain.notificationResult.MonthWhileResult;
import com.ruoyi.system.domain.notificationResult.OrderNotification;
import com.ruoyi.system.mq.createMonthPConsumer;
import com.ruoyi.system.mq.createMonthUConsumer;
import com.ruoyi.system.mq.createOrderConsumer;
import com.ruoyi.system.mq.createWileListConsumer;
import com.ruoyi.system.service.ISmartNotificationService;
import com.ruoyi.system.service.ISmartReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * SmartNotificationController
 * 小程序端的消息通知
 * @author life.
 * @date 2025/4/5
 */
@RestController
@RequestMapping("/notification")
public class SmartNotificationController {
    @Autowired
    private ISmartNotificationService iSmartNotificationService;

    @Autowired
    private createOrderConsumer rocketMQMessageProducer;

    @Autowired
    private createWileListConsumer createWileListConsumer;

    @Autowired
    private createMonthUConsumer createMonthUConsumer;
    @Autowired
    private createMonthPConsumer createMonthPConsumer;
    /**
     * 月卡涨价通知
     * @return
     */
    @RequiresPermissions("system:notification:update")
    @Log(title = "月卡涨价通知发送", businessType = BusinessType.UPDATE)
    @PostMapping("/notification_month")
    public List<MonthCardResult> monthlist() {
        List<MonthCardResult> monthCardUsersForNotice = iSmartNotificationService.getMonthCardUsersForNotice();
        createMonthUConsumer.onMessage(monthCardUsersForNotice);
        return monthCardUsersForNotice;
    }

    /**
     * 会员涨价通知
     * @return
     */
    @RequiresPermissions("system:notification:update")
    @Log(title = "会员涨价通知发送", businessType = BusinessType.UPDATE)
    @PostMapping("/notification_while")
    public  List<MonthWhileResult> whilelist() {
        List<MonthWhileResult> monthWhileUsersForNotice = iSmartNotificationService.getMonthWhileUsersForNotice();
        createWileListConsumer.onMessage(monthWhileUsersForNotice);
        return monthWhileUsersForNotice;
    }

    /**
     * 月卡过期通知
     * @return
     */
    @RequiresPermissions("system:notification:update")
    @Log(title = "月卡过期通知发送", businessType = BusinessType.UPDATE)
    @PostMapping("/notification_month_message")
    public List<MonthNotification> monthmessagelist() {
        List<MonthNotification> monthNotification = iSmartNotificationService.getMonthNotification();
        createMonthPConsumer.onMessage(monthNotification);
        return monthNotification;
    }

    /**
     * 缴费通知
     * @return
     */
//    @RequiresPermissions("system:notification:update")
    @Log(title = "缴费提醒通知发送", businessType = BusinessType.UPDATE)
    @PostMapping("/order_notification")
    public List<OrderNotification> order() {
        List<OrderNotification> orderNotifications = iSmartNotificationService.orderNotifications();
        rocketMQMessageProducer.onMessage(orderNotifications);
        return orderNotifications;
    }
}